{
  let ary = [12, 8, 88, 97, 67, 56, 78, 86, 85];

  function quickSort(ary) {
    if (ary.length <= 1) return ary
    let middleIndex = Math.floor(ary.length / 2)
    let middleVal = ary.splice(middleIndex, 1)[0]
    const left = [], right = []
    ary.forEach(v => {
      if (v > middleVal) right.push(v)
      else left.push(v)
    });
    return [...quickSort(left), middleVal, ...quickSort(right)]
  }

  console.log(quickSort(ary));
}

